//
//  BaseTableViewController.swift
//  Weibo
//
//  Created by 鹏 周 on 15/12/13.
//  Copyright © 2015年 ycit. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController,VisitorLoginViewDelegate {

    var userLogin = false
    //新建属性访客视图
    var visitorLoginView: VisitorLoginView?
    override func loadView() {
        if userLogin {
        super.loadView()
        } else {
          setVisitorLoginView()
        }
    }
    
    func userWillLogin() {
        print(__FUNCTION__)
        
        let oauth = OAuthViewController()
        //添加到 导航视图控制器
        let nav = UINavigationController(rootViewController: oauth)
        presentViewController(nav, animated: true, completion: nil)
        
    }
    
    func userWillRegister() {
        print(__FUNCTION__)
    }
    
    private func setVisitorLoginView() {
       visitorLoginView = VisitorLoginView()

        visitorLoginView?.visitroViewDelegate = self
        view = visitorLoginView
        
        self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登录", style: .Plain, target: self, action: "userWillLogin")
        self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: "userWillRegister")
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()

       
    }

  
    

}
